<!DOCTYPE html>
<html>
<head>
    <title>订单详情</title>
    #parse("sys/header.html")
    <style type="text/css">
        .col-sm-3 {
            padding-top: 7px;
        }
    </style>
</head>

<body>
<div id="viewapp" v-cloak>
    <div class="form-horizontal" style="width: 100%">
        <div class="form-group">
            <label class="control-label col-sm-2" style="font-size: 15px">今日商户交易金额：</label>
            <div class="col-sm-3" style="color: red;font-size: 16px">
                {{payorder.todayAmount}}
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-2">订单号：</label>
            <div class="col-sm-3">
                {{payorder.recordno}}
            </div>
            <label class="control-label col-sm-2">商户编号：</label>
            <div class="col-sm-3">
                {{payorder.busid}}
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-2">订单创建时间：</label>
            <div class="col-sm-3">
                {{payorder.orderdate}}
            </div>
            <label class="control-label col-sm-2" style="font-size: 15px">支付状态：</label>
            <div class="col-sm-3">
                {{payorder.status}}
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-2">来源：</label>
            <div class="col-sm-3">
                {{payorder.resourceVue}}
            </div>
            <label class="control-label col-sm-2">收款码名称/收款码编号：</label>
            <div class="col-sm-3">
                {{payorder.codeName}}/{{payorder.codeNo}}
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-sm-2">平台订单号：</label>
            <div class="col-sm-3">
                {{payorder.transactionId}}
            </div>
            <label class="control-label col-sm-2">银行类型：</label>
            <div class="col-sm-3">
                {{payorder.bankTypeVue}}
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-sm-2">收款员名称：</label>
            <div class="col-sm-3">
                {{payorder.name}}
            </div>
            <label class="control-label col-sm-2">店铺名称：</label>
            <div class="col-sm-3">
                {{payorder.shopname}}
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-2">备注：</label>
            <div class="col-sm-3">
                {{payorder.remark}}
            </div>
            <label class="control-label col-sm-2">用户备注：</label>
            <div class="col-sm-3">
                {{payorder.payremark}}
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-sm-2" style="font-size: 15px">总金额：</label>
            <div class="col-sm-3" style="color: red;font-size: 16px">
                {{payorder.amount}}
            </div>
            <label class="control-label col-sm-2">已退款金额：</label>
            <div class="col-sm-3" style="color: red;font-size: 16px">
                {{payorder.refybdAmount}}
            </div>
        </div>
        <div class="form-group" style="text-align: center">
            <input value="确认退款" class="btn btn-primary butRefund" type="button" style="width: 100px">
        </div>

    </div>

</div>

<script>
    var vm = new Vue({
        el: '#viewapp',
        data: {
            title: null,
            payorder: {},
            selected: '',
        },
        methods: {
            getInfo: function (id) {
                $.get("../payorder/info/" + id, function (r) {
                    if (r.code === 0) {
                        vm.payorder = r.payorder;
                        if (r.payorder.status == 0) {
                            vm.payorder.status = "支付失败";
                        } else if (r.payorder.status == 1) {
                            vm.payorder.status = "已付款";
                        } else if (r.payorder.status == 2) {
                            vm.payorder.status = "已退款";
                        } else if (r.payorder.status == 3) {
                            vm.payorder.status = "已对账";
                        } else if (r.payorder.status == 4) {
                            vm.payorder.status = "已关闭";
                        } else if (r.payorder.status == 5) {
                            vm.payorder.status = "退款处理中";
                        } else if (r.payorder.status == 6) {
                            vm.payorder.status = "未确定，需重新发起";
                        } else if (r.payorder.status == 7) {
                            vm.payorder.status = "转入代发";
                        } else if (r.payorder.status == 9) {
                            vm.payorder.status = "异常";
                        } else if (r.payorder.status == 10) {
                            vm.payorder.status = "转入退款";
                        } else if (r.payorder.status == 11) {
                            vm.payorder.status = "未支付";
                        } else if (r.payorder.status == 12) {
                            vm.payorder.status = "已冲正";
                        } else if (r.payorder.status == 13) {
                            vm.payorder.status = "已撤销";
                        } else {
                            vm.payorder.status = "";
                        }
                        if (r.bool) {
                            $(".butRefund").show();
                        } else {
                            $(".butRefund").hide();
                        }
                    }
                });
            },
            view: function (id) {
                console.log(this.$route.query.id);
            },
        }
    });
    $(function () {
        //获取网页参数
        (function ($) {
            $.getUrlParam = function (name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null)
                    return unescape(r[2]);
                return null;
            }
        })(jQuery);
        id = $.getUrlParam('id');
        vm.getInfo(id);
    });

    $(".butRefund").click(function() {
        var indexW = parent.layer.getFrameIndex(window.name); //获取当前窗体索引
        confirm('确认要退款吗？', function(){
            $.ajax({
                type: "POST",
                url: "../payorder/orderRefund",
                data: JSON.stringify(vm.payorder.id),
                success: function (r) {
                    if (r.code === 0) {
                        alert('操作成功', function (index) {
                            parent.layer.close(indexW);
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        });
    });

</script>
</body>
</html>